package com.company.util;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.log4j.Logger;


public class CollectionUtil
{
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger.getLogger(CollectionUtil.class);


	public static void printMap(Map map)
	{
		Set keySet = map.keySet();
		Iterator iter = keySet.iterator();
		while(iter.hasNext())
		{
			Object key = iter.next();
			logger.debug("Key[" + key + "]=" + map.get(key));
		}
	}
	
	public static void printList(List list)
	{
		Object[] objects = list.toArray();
		for(int i=0;i<objects.length;i++)
		{	
			logger.debug("Key[" + i + "]=" + objects[i]);
		}
		
	}
	
	public static Map transMap(List list)
	{
		Map map = new HashMap();
		
		Object[] objects = list.toArray();
		for(int i=0;i<objects.length;i++)
		{	
			String s = (String) objects[i];
			String name = s.substring(0 , s.indexOf('='));
			String value = s.substring(s.indexOf('=') + 1);
			map.put(name , value);

		}
		return map;
		
	}

}
